<?php
//App::import('slideshow');
class SlidesController extends AppController
{
    var $name = 'Slides';
    var $scaffold;
    
    var $helpers = array('Slideshow','Js', 'Html');
    //var $components = array('Slideshow');
    
    /**
     * This method starts a slideshow for this active feed
     *
     * @param int $id ID of the feed
     * @param int $page pagenumber
     */
    function slideshow($feed = 1, $page = 1)
    {
		//$mypaging = $this->Slideshow;
		
		// the chosen slide is searched here
		//$data = $this->Slide->find('all');
		$data = $this->Slide->find('first',
			array('order'=>'order', 
		          'limit'=>1,
		          'page'=>$page,
		          'feed'=>$feed, 
		          'conditions'=>
				  	array('Slide.feed_id' => $feed,
						  'Slide.visible' => true)
						  //'Slide.show_from <=' => 'CURRENT_TIMESTAMP()',
						  //'Slide.show_till >=' => 'CURRENT_TIMESTAMP()')
				  )
		);
		$this->set('slides', $data);
		//$this->set('mypaging', $mypaging);
		//print_r($this);
		$this->autoLayout=1; // disables the header/footer of the page
		
    }
    
    /**
     * Get the slide of the specified id
     *
     * @param int $id
     */
    function view($id = null)
    {
	        $this->Slide->id = $id;
	        $this->set('slide', $this->Slide->read());
    }
}

?>